/**
 *ZHU framework. Copyright 2007-, all rights reserved.
 *
 * $Id$
 * $Revision$
 * $Date$
 * $Author$
 */
package daily.web.period;

import java.util.*;

/**
 * @author xiaopengzhu
 * 
 */
public final class DateRange {

	private DateRange(final Date date, final PeriodType periodType) {
		this.date = date;
		this.periodType = periodType;
	}

	public static DateRange of(final Date date, final PeriodType periodType) {
		return new DateRange(date, periodType);
	}

	public DateRange current() {
		return of(new Date(), periodType);
	}

	public DateRange prior() {
		return of(periodType.prior(date), periodType);
	}

	public DateRange next() {
		return of(periodType.next(date), periodType);
	}

	public PeriodType getPeriodType() {
		return periodType;
	}

	public Date getDate() {
		return date;
	}

	private final PeriodType periodType;
	private final Date date;
}
